import React from 'react';
import { Tag, Tooltip, Space, Button, Popconfirm } from 'antd';
import moment from 'moment';

// 商标状态选项
export const trademarkStatusOptions = [
  { value: '申请中', label: '申请中' },
  { value: '已注册', label: '已注册' },
  { value: '已驳回', label: '已驳回' },
  { value: '已过期', label: '已过期' },
  { value: '已放弃', label: '已放弃' }
];

// 获取标签颜色
export const getStatusColor = (status) => {
  switch (status) {
    case '申请中':
      return 'blue';
    case '已注册':
      return 'green';
    case '已驳回':
      return 'red';
    case '已过期':
      return 'gray';
    case '已放弃':
      return 'orange';
    default:
      return 'default';
  }
};

// 国际分类选项
export const internationalClassOptions = [
  { value: '1', label: '1类-化学制品' },
  { value: '2', label: '2类-颜料油漆' },
  { value: '3', label: '3类-日化用品' },
  { value: '4', label: '4类-燃料油脂' },
  { value: '5', label: '5类-医药' },
  { value: '6', label: '6类-金属材料' },
  { value: '7', label: '7类-机械设备' },
  { value: '8', label: '8类-手工器械' },
  { value: '9', label: '9类-科学仪器' },
  { value: '10', label: '10类-医疗器械' },
  { value: '11', label: '11类-灯具空调' },
  { value: '12', label: '12类-运输工具' },
  { value: '13', label: '13类-军火烟火' },
  { value: '14', label: '14类-珠宝钟表' },
  { value: '15', label: '15类-乐器' },
  { value: '16', label: '16类-办公用品' },
  { value: '17', label: '17类-橡胶制品' },
  { value: '18', label: '18类-皮革皮具' },
  { value: '19', label: '19类-建筑材料' },
  { value: '20', label: '20类-家具' },
  { value: '21', label: '21类-厨房洁具' },
  { value: '22', label: '22类-绳网袋篷' },
  { value: '23', label: '23类-纱线丝' },
  { value: '24', label: '24类-布料床单' },
  { value: '25', label: '25类-服装鞋帽' },
  { value: '26', label: '26类-饰品编带' },
  { value: '27', label: '27类-地毯席垫' },
  { value: '28', label: '28类-健身器材' },
  { value: '29', label: '29类-肉奶蛋食品' },
  { value: '30', label: '30类-方便食品' },
  { value: '31', label: '31类-农林生鲜' },
  { value: '32', label: '32类-啤酒饮料' },
  { value: '33', label: '33类-酒' },
  { value: '34', label: '34类-烟草烟具' },
  { value: '35', label: '35类-广告销售' },
  { value: '36', label: '36类-金融物管' },
  { value: '37', label: '37类-建筑修理' },
  { value: '38', label: '38类-通讯服务' },
  { value: '39', label: '39类-运输贮藏' },
  { value: '40', label: '40类-材料加工' },
  { value: '41', label: '41类-教育娱乐' },
  { value: '42', label: '42类-科技服务' },
  { value: '43', label: '43类-餐饮住宿' },
  { value: '44', label: '44类-医疗园艺' },
  { value: '45', label: '45类-社会法律' }
];

// 生成表格列定义
export const getColumns = (onEdit, onDelete) => [
  {
    title: '序号',
    dataIndex: 'id',
    key: 'id',
    width: 60,
    render: (text, record, index) => index + 1
  },
  {
    title: '商标',
    dataIndex: 'trademark',
    key: 'trademark',
    width: 100,
    ellipsis: true,
    render: (text) => <Tooltip title={text}>{text || '-'}</Tooltip>
  },
  {
    title: '商标名称',
    dataIndex: 'trademark_name',
    key: 'trademark_name',
    width: 150,
    ellipsis: true,
    render: (text) => <Tooltip title={text}>{text || '-'}</Tooltip>
  },
  {
    title: '注册号',
    dataIndex: 'registration_number',
    key: 'registration_number',
    width: 120,
    ellipsis: true,
    render: (text) => <Tooltip title={text}>{text || '-'}</Tooltip>
  },
  {
    title: '国际分类',
    dataIndex: 'international_class',
    key: 'international_class',
    width: 120,
    ellipsis: true,
    render: (text) => {
      const option = internationalClassOptions.find(opt => opt.value === text);
      return <Tooltip title={option ? option.label : text}>{option ? option.label : text || '-'}</Tooltip>;
    }
  },
  {
    title: '申请日期',
    dataIndex: 'application_date',
    key: 'application_date',
    width: 110,
    render: (text) => text ? moment(text).format('YYYY-MM-DD') : '-'
  },
  {
    title: '商标状态',
    dataIndex: 'trademark_status',
    key: 'trademark_status',
    width: 100,
    render: (status) => {
      if (!status) return '-';
      const color = getStatusColor(status);
      return <Tag color={color}>{status}</Tag>;
    }
  },
  {
    title: '注册公告日期',
    dataIndex: 'registration_announcement_date',
    key: 'registration_announcement_date',
    width: 120,
    render: (text) => text ? moment(text).format('YYYY-MM-DD') : '-'
  },
  {
    title: '到期日期',
    dataIndex: 'expiration_date',
    key: 'expiration_date',
    width: 110,
    render: (text) => text ? moment(text).format('YYYY-MM-DD') : '-'
  },
  {
    title: '描述',
    dataIndex: 'description',
    key: 'description',
    ellipsis: true,
    render: (text) => <Tooltip title={text}>{text || '-'}</Tooltip>
  },
  {
    title: '操作',
    key: 'action',
    fixed: 'right',
    width: 120,
    render: (_, record) => (
      <Space size="small">
        <Button type="link" onClick={() => onEdit(record)} size="small">编辑</Button>
        <Popconfirm
          title="确定要删除此商标吗？"
          onConfirm={() => onDelete(record)}
          okText="确定"
          cancelText="取消"
        >
          <Button type="link" danger size="small">删除</Button>
        </Popconfirm>
      </Space>
    )
  }
]; 